package main

import "fmt"

type Cat struct {
	Name string
	Age  int
	Addr string
}

func main() {
	//赋值创建
	//var cat Cat
	//cat.Addr = "浙江"
	//cat.Name = "张三"
	//cat.Age = 20
	//
	//fmt.Println(cat)
	//
	//test1()

	test2()

}

//有参构造方法创建
func test1() {
	cat := Cat{"hang", 32, "安徽"}
	fmt.Println(cat)
}

//结构体默认是值拷贝, 如果是指针传递需要特殊写法
func test2() {
	var p1 = Person{}
	p1.Name = "zhangsan"
	p1.Age = 210

	p2 := &p1
	(*p2).Name = "lisi"
	p2.Age = 12
	fmt.Println("p1的值", p1, "p1的地址", &p1)
	fmt.Println("p2的值", *p2, "p2的地址", &p2)

}

type Person struct {
	Name string
	Age  int
}
